<?php

namespace App\Service\Push;

use App\Http\Middleware\OpenShop\UserPermissionAuth;
use App\Service\BaseService;

/**
 * 推送 - 基础配置&常量
 */
class PushConfigService extends BaseService
{
    // 业务
    const BIZ_TYPE_USER     = 1; // 按人推送
    const BIZ_TYPE_KF       = 2; // 全公司推送
    const BIZ_TYPE_PROVINCE = 3; // 省区推送

    const BIZ_LISTS = [
        self::BIZ_TYPE_USER,
        self::BIZ_TYPE_KF,
        self::BIZ_TYPE_PROVINCE,
    ];

    // 小程序类型
    const APP_TYPE_OPEN       = 11; // 开店
    const APP_TYPE_SITE       = 12; // 选址
    const APP_TYPE_INCREASE   = 13; // 增长
    const APP_TYPE_CHECK      = 14; // 稽核
    const APP_TYPE_COLLEGE    = 15; // 商学院
    const APP_TYPE_WORK_ORDER = 16; // 工单

    const APP_MODULE = [
        self::APP_TYPE_OPEN     => UserPermissionAuth::MODULE_OPEN_SHOP,
        self::APP_TYPE_SITE     => UserPermissionAuth::MODULE_OPEN_SITE,
        self::APP_TYPE_INCREASE => UserPermissionAuth::MODULE_CRUISE,
        self::APP_TYPE_CHECK    => UserPermissionAuth::MODULE_CRUISE_CHECK,
    ];

    // 公司统计范围
    const REGION_TYPE_PROVINCE = 21; // 省区
    const REGION_TYPE_KF       = 22; // 总部
    const REGION_TYPE_EXT      = 23; // 三方

    // 部门
    const DEPARTMENT_COLLEGE           = 31; // 创业商学院
    const DEPARTMENT_OPERATE           = 32; // 在线运营中心
    const DEPARTMENT_MARKET_INCREASE   = 33; // 市场增长中心
    const DEPARTMENT_SUPPLIER          = 34; // 供应链
    const DEPARTMENT_QUALITY_CTRL      = 35; // 品控
    const DEPARTMENT_SITE              = 36; // 选址开发大客户部
    const DEPARTMENT_DESIGN            = 37; // 品牌设计中心
    const DEPARTMENT_MERCHANT_INCREASE = 38; // 商家增长中心
    const DEPARTMENT_BUSINESS          = 39; // 业务运营部
    const DEPARTMENT_INCREASE_SCHOOL   = 40; // 增长研究院

    // 任务明细
    const TASK_JOIN_PAY  = 101;
    const TASK_JOIN_SIGN = 102;

    const TASK_DESIGN_ASSIGN       = 111;
    const TASK_DESIGN_DESIGN_ORDER = 112;
    const TASK_DESIGN_EQUIP_ORDER  = 113;
    const TASK_DESIGN_SOFT_ORDER   = 114;

    const TASK_PREPARE_BUILD        = 121;
    const TASK_PREPARE_DESIGN_PAY   = 122;
    const TASK_PREPARE_EQUIP_PAY    = 123;
    const TASK_PREPARE_SOFT_PAY     = 124;
    const TASK_PREPARE_ENTER        = 125;
    const TASK_PREPARE_CONSTRUCTION = 126;
    const TASK_PREPARE_STORE_HELP   = 127;

    const TASK_PROVINCE_DEVELOP_ASSIGN = 131;
    const TASK_PROVINCE_SITE_AUDIT     = 132;

    const TASK_DEVELOP_SITE_SUBMIT      = 141;
    const TASK_DEVELOP_SITE_EDIT        = 142;
    const TASK_DEVELOP_HOUSE_EDIT       = 143;
    const TASK_DEVELOP_MERCHANT_CONFIRM = 144;
    const TASK_SITE_HOUSE_AUDIT         = 145;
    const TASK_SITE_SITE_AUDIT          = 146;

    const TASK_INCREASE_SUBMIT = 151;
    const TASK_INCREASE_EDIT   = 152;
    const TASK_INCREASE_AUDIT  = 153;

    const TASK_CHECK_KF_SUBMIT  = 161;
    const TASK_CHECK_EXT_SUBMIT = 162;
    const TASK_CHECK_EXT_EDIT   = 163;
    const TASK_CHECK_AUDIT      = 164;

    const TASK_COLLEGE_KF_CONFIRM       = 171;
    const TASK_COLLEGE_MERCHANT_CONFIRM = 172;

    const TASK_WORK_ORDER_WM      = 181;
    const TASK_WORK_ORDER_SY      = 182;
    const TASK_WORK_ORDER_DP      = 183;
    const TASK_WORK_ORDER_DY      = 184;
    const TASK_WORK_ORDER_STORE   = 185;
    const TASK_WORK_ORDER_EQUIP   = 186;
    const TASK_WORK_ORDER_QUALITY = 187;
    const TASK_WORK_ORDER_SOFT_RZ = 188;
    const TASK_WORK_ORDER_SOFT_BT = 189;
    const TASK_WORK_ORDER_SOFT_DJ = 190;

    // 商家部分任务
    const MERCHANT_TASKS = [
        self::TASK_JOIN_PAY,
        self::TASK_JOIN_SIGN,
        self::TASK_PREPARE_DESIGN_PAY,
        self::TASK_PREPARE_EQUIP_PAY,
        self::TASK_PREPARE_SOFT_PAY,
        self::TASK_DEVELOP_MERCHANT_CONFIRM,
        self::TASK_COLLEGE_MERCHANT_CONFIRM,
    ];

    const ENUM_TEXT = [

        // 小程序类型
        self::APP_TYPE_OPEN                => '开店',
        self::APP_TYPE_SITE                => '选址',
        self::APP_TYPE_INCREASE            => '增长',
        self::APP_TYPE_CHECK               => '稽核',
        self::APP_TYPE_COLLEGE             => '商学院',
        self::APP_TYPE_WORK_ORDER          => '工单',

        // 公司统计范围
        self:: REGION_TYPE_PROVINCE        => '省区',
        self:: REGION_TYPE_KF              => '总部',
        self:: REGION_TYPE_EXT             => '三方',

        // 部门
        self::DEPARTMENT_COLLEGE           => '创业商学院',
        self::DEPARTMENT_OPERATE           => '在线运营中心',
        self::DEPARTMENT_MARKET_INCREASE   => '市场增长中心',
        self::DEPARTMENT_SUPPLIER          => '供应链管理中心',
        self::DEPARTMENT_QUALITY_CTRL      => '品控管理中心',
        self::DEPARTMENT_SITE              => '选址开发大客户部',
        self::DEPARTMENT_DESIGN            => '品牌设计中心',
        self::DEPARTMENT_MERCHANT_INCREASE => '商家增长中心',
        self::DEPARTMENT_BUSINESS          => '业务运营部',
        self::DEPARTMENT_INCREASE_SCHOOL   => '增长研究院',

        // 任务
        self::TASK_JOIN_PAY                => '商家加盟费待支付',
        self::TASK_JOIN_SIGN               => '商家加盟费待签约',
        self::TASK_DESIGN_ASSIGN           => '指派设计师',
        self::TASK_DESIGN_DESIGN_ORDER     => '下设计单',
        self::TASK_DESIGN_EQUIP_ORDER      => '下设备单',
        self::TASK_DESIGN_SOFT_ORDER       => '下软装单',
        self::TASK_PREPARE_BUILD           => '确认建店',
        self::TASK_PREPARE_DESIGN_PAY      => '商家设计款支付',
        self::TASK_PREPARE_EQUIP_PAY       => '商家设备款支付',
        self::TASK_PREPARE_SOFT_PAY        => '商家软装款支付',
        self::TASK_PREPARE_ENTER           => '进场待确认',
        self::TASK_PREPARE_CONSTRUCTION    => '进场待施工',
        self::TASK_PROVINCE_DEVELOP_ASSIGN => '开发待指派',
        self::TASK_PREPARE_STORE_HELP      => '新店帮扶',

        self::TASK_PROVINCE_SITE_AUDIT      => '选址待审核',
        self::TASK_DEVELOP_SITE_SUBMIT      => '选址待提交',
        self::TASK_DEVELOP_SITE_EDIT        => '选址待修改',
        self::TASK_DEVELOP_HOUSE_EDIT       => '房源待修改',
        self::TASK_DEVELOP_MERCHANT_CONFIRM => '商家待确认',
        self::TASK_SITE_HOUSE_AUDIT         => '房源待审核',
        self::TASK_SITE_SITE_AUDIT          => '选址待审批',

        self::TASK_INCREASE_SUBMIT => '增长-待提交',
        self::TASK_INCREASE_EDIT   => '增长-待修改',
        self::TASK_INCREASE_AUDIT  => '增长-待审批',

        self::TASK_CHECK_KF_SUBMIT  => '稽核-待提交',
        self::TASK_CHECK_EXT_SUBMIT => '三方稽核-待提交',
        self::TASK_CHECK_EXT_EDIT   => '三方稽核-待修改',
        self::TASK_CHECK_AUDIT      => '稽核-待审核',

        self::TASK_COLLEGE_KF_CONFIRM       => '创业商学院 - 商学院待确认',
        self::TASK_COLLEGE_MERCHANT_CONFIRM => '创业商学院 - 商家待确认',
        self::TASK_WORK_ORDER_WM            => '工单-功能开通-外卖',
        self::TASK_WORK_ORDER_SY            => '工单-功能开通-私域',
        self::TASK_WORK_ORDER_DP            => '工单-功能开通-点评',
        self::TASK_WORK_ORDER_DY            => '工单-功能开通-抖音',
        self::TASK_WORK_ORDER_STORE         => '工单-仓储配送',
        self::TASK_WORK_ORDER_EQUIP         => '工单-设备软装-设备类',
        self::TASK_WORK_ORDER_QUALITY       => '工单-品控异常',
        self::TASK_WORK_ORDER_SOFT_RZ       => '工单-设备软装-软装',
        self::TASK_WORK_ORDER_SOFT_BT       => '工单-设备软装-吧台',
        self::TASK_WORK_ORDER_SOFT_DJ       => '工单-设备软装-道具',
    ];

    // 模块对应的任务
    const APP_TYPE_TO_TASKS = [

        // 开店 13
        self::APP_TYPE_OPEN       => [
            self::TASK_JOIN_PAY,
            self::TASK_JOIN_SIGN,
            self::TASK_DESIGN_ASSIGN,
            self::TASK_DESIGN_DESIGN_ORDER,
            self::TASK_DESIGN_EQUIP_ORDER,
            self::TASK_DESIGN_SOFT_ORDER,
            self::TASK_PREPARE_BUILD,
            self::TASK_PREPARE_DESIGN_PAY,
            self::TASK_PREPARE_EQUIP_PAY,
            self::TASK_PREPARE_SOFT_PAY,
            self::TASK_PREPARE_ENTER,
            self::TASK_PREPARE_CONSTRUCTION,
            self::TASK_PROVINCE_DEVELOP_ASSIGN,
            self::TASK_PREPARE_STORE_HELP,
        ],

        // 选址 7
        self::APP_TYPE_SITE       => [
            self::TASK_PROVINCE_SITE_AUDIT,
            self::TASK_DEVELOP_SITE_SUBMIT,
            self::TASK_DEVELOP_SITE_EDIT,
            self::TASK_DEVELOP_HOUSE_EDIT,
            self::TASK_DEVELOP_MERCHANT_CONFIRM,
            self::TASK_SITE_HOUSE_AUDIT,
            self::TASK_SITE_SITE_AUDIT,
        ],

        // 增长 3
        self::APP_TYPE_INCREASE   => [
            self::TASK_INCREASE_SUBMIT,
            self::TASK_INCREASE_EDIT,
            self::TASK_INCREASE_AUDIT,
        ],

        // 稽核 4
        self::APP_TYPE_CHECK      => [
            self::TASK_CHECK_KF_SUBMIT,
            self::TASK_CHECK_EXT_SUBMIT,
            self::TASK_CHECK_EXT_EDIT,
            self::TASK_CHECK_AUDIT,
        ],

        // 商学院 2
        self::APP_TYPE_COLLEGE    => [
            self::TASK_COLLEGE_KF_CONFIRM,
            self::TASK_COLLEGE_MERCHANT_CONFIRM,
        ],

        // 工单 10
        self::APP_TYPE_WORK_ORDER => [
            self::TASK_WORK_ORDER_WM,
            self::TASK_WORK_ORDER_SY,
            self::TASK_WORK_ORDER_DP,
            self::TASK_WORK_ORDER_DY,
            self::TASK_WORK_ORDER_STORE,
            self::TASK_WORK_ORDER_EQUIP,
            self::TASK_WORK_ORDER_QUALITY,
            self::TASK_WORK_ORDER_SOFT_RZ,
            self::TASK_WORK_ORDER_SOFT_BT,
            self::TASK_WORK_ORDER_SOFT_DJ,
        ],
    ];

    public static function frame(): array
    {
        return [

            // 按人推送 - 全量任务
            self::BIZ_TYPE_USER     => self::APP_TYPE_TO_TASKS,

            // 全公司推送
            self::BIZ_TYPE_KF       => [

                // 省区
                self::REGION_TYPE_PROVINCE => $provinceArr = [
                    self::APP_TYPE_OPEN     => [
                        self::TASK_PROVINCE_DEVELOP_ASSIGN,
                    ],
                    self::APP_TYPE_SITE     => [
                        self::TASK_PROVINCE_SITE_AUDIT,
                        self::TASK_DEVELOP_SITE_SUBMIT,
                        self::TASK_DEVELOP_SITE_EDIT,
                        self::TASK_DEVELOP_HOUSE_EDIT,
                        self::TASK_DEVELOP_MERCHANT_CONFIRM,
                    ],
                    self::APP_TYPE_INCREASE => [
                        self::TASK_INCREASE_SUBMIT,
                        self::TASK_INCREASE_EDIT,
                        self::TASK_INCREASE_AUDIT,
                    ],
                    self::APP_TYPE_CHECK    => [
                        self::TASK_CHECK_KF_SUBMIT
                    ],
                ],

                // 总部
                self::REGION_TYPE_KF       => [
                    self::DEPARTMENT_COLLEGE           => [
                        self::TASK_COLLEGE_KF_CONFIRM,
                        self::TASK_COLLEGE_MERCHANT_CONFIRM,
                    ],
                    self::DEPARTMENT_OPERATE           => [
                        self::TASK_WORK_ORDER_WM,
                        self::TASK_WORK_ORDER_SY,
                        self::TASK_WORK_ORDER_DP,
                    ],
                    self::DEPARTMENT_MARKET_INCREASE   => [
                        self::TASK_WORK_ORDER_DY,
                    ],
                    self::DEPARTMENT_SUPPLIER          => [
                        self::TASK_WORK_ORDER_EQUIP,
                    ],
                    self::DEPARTMENT_QUALITY_CTRL      => [
                        self::TASK_WORK_ORDER_STORE,
                    ],
                    self::DEPARTMENT_SITE              => [
                        self::TASK_DEVELOP_SITE_SUBMIT,
                        self::TASK_DEVELOP_MERCHANT_CONFIRM,
                    ],
                    self::DEPARTMENT_DESIGN            => [
                        self::TASK_DESIGN_ASSIGN,
                        self::TASK_DESIGN_DESIGN_ORDER,
                        self::TASK_DESIGN_EQUIP_ORDER,
                        self::TASK_DESIGN_SOFT_ORDER,
                    ],
                    self::DEPARTMENT_MERCHANT_INCREASE => [
                        self::TASK_JOIN_PAY,
                        self::TASK_JOIN_SIGN,
                    ],
                    self::DEPARTMENT_BUSINESS          => [
                        self::TASK_PREPARE_BUILD,
                        self::TASK_PREPARE_DESIGN_PAY,
                        self::TASK_PREPARE_EQUIP_PAY,
                        self::TASK_PREPARE_SOFT_PAY,
                        self::TASK_PREPARE_ENTER,
                        self::TASK_PREPARE_CONSTRUCTION,
                        self::TASK_PREPARE_STORE_HELP,
                        self::TASK_WORK_ORDER_SOFT_RZ,
                        self::TASK_WORK_ORDER_SOFT_BT,
                        self::TASK_WORK_ORDER_SOFT_DJ,
                    ],
                    self::DEPARTMENT_INCREASE_SCHOOL   => [
                        self::TASK_SITE_HOUSE_AUDIT,
                        self::TASK_SITE_SITE_AUDIT,
                        self::TASK_PROVINCE_SITE_AUDIT,
                    ],
                ],

                // 三方
                self::REGION_TYPE_EXT      => [
                    self::APP_TYPE_CHECK => [
                        self::TASK_CHECK_EXT_SUBMIT,
                        self::TASK_CHECK_EXT_EDIT,
                    ],
                ],
            ],

            // 分公司推送
            self::BIZ_TYPE_PROVINCE => $provinceArr, // 复用 - 按省区
        ];
    }
}
